package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.card.EntityXfGoodsListProcess;
import com.ocom.common.vo.payconfig.MealDateSummaryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface IDaoXfGoodsListProcess extends BaseMapper<EntityXfGoodsListProcess> {


    @Select({"<script>",
            "select  D.meal_date as mealDate , D.meal_no as mealNo , M.meal_name as mealName, \n" +
                    "D.dishes_id as dishesId , count(D.id) as orderNumber \n" +
                    "from  xf_goods_list_process as D, xf_record_process as R    \n" +
                    "left join xf_meal_info M  on M.com_id = #{comId}  and  M.meal_no = R.meal_no \n" +
                    "where  R.order_no = D.order_no  and  D.com_id = #{comId} " +
                    " <when test=\"pointId!=-1 \" > " +
                    " and  D.point_id = #{pointId}  \n" +
                    "</when>" +
//                    "and  D.meal_no in (@mealNos )  " +
                    " <when test=\"mealNos != null and mealNos.size() &gt; 0 \" > " +
                    " and    D.meal_no in  " +
                    " <foreach collection='mealNos' item='id' open='(' separator=',' close=')'> " +
                    " #{id} " +
                    " </foreach> " +
                    "</when>" +
                    "and  D.meal_date <![CDATA[ >= ]]> #{beginDate}  and  D.meal_date <![CDATA[ <= ]]> #{endDate} \n" +
                    "and  R.cons_state = 5  and  D.if_refund = 0 and R.pay_state=1 \n" +
                    "group by  mealDate , mealNo ,dishesId \n" +
                    "order by  mealDate , mealNo" +
                    "</script>"})
    List<MealDateSummaryVo> mealDateSummary(@Param("comId")Long comId,
                                        @Param("pointId")Integer pointId,
                                        @Param("mealNos") List<Integer> mealNos,
                                        @Param("beginDate")String beginDate,
                                        @Param("endDate")String endDate

    );

}
